DEFINITION FOR LIBRARY MODULE Locale ;

FROM SYSTEM	IMPORT ADDRESS, STRING, LONGSET ;
FROM Exec	IMPORT Library, Node ;
FROM Utility	IMPORT TagItemPtr, Tag, TAG_USER, HookPtr ;
FROM Dos	IMPORT DateStampPtr ;

(* constants for GetLocaleStr() *)
CONST
  DAY_1		= 1 ;	(* Sunday    *)
  DAY_2		= 2 ;	(* Monday    *)
  DAY_3		= 3 ;	(* Tuesday   *)
  DAY_4		= 4 ;	(* Wednesday *)
  DAY_5		= 5 ;	(* Thursday  *)
  DAY_6		= 6 ;	(* Friday    *)
  DAY_7		= 7 ;	(* Saturday  *)

  ABDAY_1	= 8 ;	(* Sun *)
  ABDAY_2	= 9 ;	(* Mon *)
  ABDAY_3	= 10 ;	(* Tue *)
  ABDAY_4	= 11 ;	(* Wed *)
  ABDAY_5	= 12 ;	(* Thu *)
  ABDAY_6	= 13 ;	(* Fri *)
  ABDAY_7	= 14 ;	(* Sat *)

  MON_1		= 15 ;	(* January   *)
  MON_2		= 16 ;	(* February  *)
  MON_3		= 17 ;	(* March     *)
  MON_4		= 18 ;	(* April     *)
  MON_5		= 19 ;	(* May	     *)
  MON_6		= 20 ;	(* June      *)
  MON_7		= 21 ;	(* July      *)
  MON_8		= 22 ;	(* August    *)
  MON_9		= 23 ;	(* September *)
  MON_10	= 24 ;	(* October   *)
  MON_11	= 25 ;	(* November  *)
  MON_12	= 26 ;	(* December  *)

  ABMON_1	= 27 ;	(* Jan *)
  ABMON_2	= 28 ;	(* Feb *)
  ABMON_3	= 29 ;	(* Mar *)
  ABMON_4	= 30 ;	(* Apr *)
  ABMON_5	= 31 ;	(* May *)
  ABMON_6	= 32 ;	(* Jun *)
  ABMON_7	= 33 ;	(* Jul *)
  ABMON_8	= 34 ;	(* Aug *)
  ABMON_9 	= 35 ;  (* Sep *)
  ABMON_10	= 36 ;	(* Oct *)
  ABMON_11	= 37 ;	(* Nov *)
  ABMON_12	= 38 ;	(* Dec *)

  YESSTR	= 39 ;	(* affirmative response for yes/no queries *)
  NOSTR		= 40 ;	(* negative response for yes/no queries    *)

  AM_STR	= 41 ;	(* AM *)
  PM_STR	= 42 ;	(* PM *)

  SOFTHYPHEN	= 43 ;	(* soft hyphenation *)
  HARDHYPHEN	= 44 ;	(* hard hyphenation *)

  OPENQUOTE	= 45 ;	(* start of quoted block *)
  CLOSEQUOTE	= 46 ;	(* end of quoted block	 *)

  YESTERDAYSTR	= 47 ;	(* Yesterday *)
  TODAYSTR	= 48 ;	(* Today     *)
  TOMORROWSTR	= 49 ;	(* Tomorrow  *)
  FUTURESTR	= 50 ;	(* Future    *)

  MAXSTRMSG	= 51 ;	(* current number of defined strings *)

(*===========================================================================*)

(* OpenLibrary("locale.library",0) returns a pointer to this structure *)
TYPE
  LocaleBasePtr = POINTER TO LocaleBaseRec ;
  LocaleBaseRec = RECORD
    lb_LibNode    : Library  ;
    lb_SysPatches : CARDINAL ;   (* TRUE if locale installed its patches *)
  END ;

(*===========================================================================*)

(* This structure must only be allocated by locale.library and is READ-ONLY! *)
TYPE
  LocalePtr = POINTER TO Locale ;
  Locale = RECORD
    loc_LocaleName		: STRING ;   (* locale's name		     *)
    loc_LanguageName		: STRING ;   (* language of this locale      *)
    loc_PrefLanguages		: ARRAY [0..9] OF STRING ;
   					     (* preferred languages	     *)
    loc_Flags			: LONGSET ;  (* always 0 for now	     *)

    loc_CodeSet			: LONGINT ;  (* always 0 for now	     *)
    loc_CountryCode		: LONGINT ;  (* user's country code	     *)
    loc_TelephoneCode		: LONGINT ;  (* country's telephone code     *)
    loc_GMTOffset		: LONGINT ;  (* minutes from GMT	     *)
    loc_MeasuringSystem		: SHORTCARD ;
    					     (* what measuring system?       *)
    loc_CalendarType		: SHORTCARD ;(* what calendar type?	     *)
    loc_Reserved0		: ARRAY [0..1] OF SHORTCARD ;

    loc_DateTimeFormat		: STRING ;   (* regular date & time format   *)
    loc_DateFormat		: STRING ;   (* date format by itself	     *)
    loc_TimeFormat		: STRING ;   (* time format by itself	     *)

    loc_ShortDateTimeFormat	: STRING ;   (* short date & time format     *)
    loc_ShortDateFormat		: STRING ;   (* short date format by itself  *)
    loc_ShortTimeFormat		: STRING ;   (* short time format by itself  *)

    (* for numeric values *)
    loc_DecimalPoint		: STRING ;   (* character before the decimals*)
    loc_GroupSeparator		: STRING ;   (* separates groups of digits   *)
    loc_FracGroupSeparator	: STRING ;   (* separates groups of digits   *)
    loc_Grouping		: ADDRESS ;  (* size of each group	     *)
    loc_FracGrouping		: ADDRESS ;  (* size of each group	     *)

    (* for monetary values *)
    loc_MonDecimalPoint		: STRING ;
    loc_MonGroupSeparator	: STRING ;
    loc_MonFracGroupSeparator	: STRING ;
    loc_MonGrouping		: ADDRESS ;
    loc_MonFracGrouping		: ADDRESS ;
    loc_MonFracDigits		: SHORTCARD;(* digits after the decimal point *)
    loc_MonIntFracDigits	: SHORTCARD;(*for international representation*)
    loc_Reserved1		: ARRAY [0..1] OF SHORTCARD ;

    (* for currency symbols *)
    loc_MonCS			: STRING ; (* currency symbol		      *)
    loc_MonSmallCS		: STRING ; (* symbol for small amounts        *)
    loc_MonIntCS		: STRING ; (* internationl (ISO 4217) code    *)

    (* for positive monetary values *)
    loc_MonPositiveSign		: STRING ;    (* indicate positive money value*)
    loc_MonPositiveSpaceSep	: SHORTCARD ; (* determine if separated by sp *)
    loc_MonPositiveSignPos	: SHORTCARD ; (* position of positive sign    *)
    loc_MonPositiveCSPos	: SHORTCARD ; (* position of currency symbol  *)
    loc_Reserved2		: SHORTCARD ;

    (* for negative monetary values *)
    loc_MonNegativeSign		: STRING ;   (* indicate negative money value *)
    loc_MonNegativeSpaceSep	: SHORTCARD ;(* determine if separated byspace*)
    loc_MonNegativeSignPos	: SHORTCARD ;(* position of negative sign     *)
    loc_MonNegativeCSPos	: SHORTCARD ;(* position of currency symbol   *)
    loc_Reserved3		: SHORTCARD ;
 END ;

(* constants for Locale.loc_MeasuringSystem *)
CONST
  MS_ISO	= 0 ;	(* international metric system *)
  MS_AMERICAN	= 1 ;	(* american system	       *)
  MS_IMPERIAL	= 2 ;	(* imperial system	       *)
  MS_BRITISH	= 3 ;	(* british system	       *)

(* constants for Locale.loc_CalendarType *)
  CT_7SUN	= 0 ;   (* 7 days a week, Sunday is the first day	*)
  CT_7MON	= 1 ;   (* 7 days a week, Monday is the first day	*)
  CT_7TUE	= 2 ;   (* 7 days a week, Tuesday is the first day	*)
  CT_7WED	= 3 ;   (* 7 days a week, Wednesday is the first day	*)
  CT_7THU	= 4 ;   (* 7 days a week, Thursday is the first day	*)
  CT_7FRI	= 5 ;   (* 7 days a week, Friday is the first day	*)
  CT_7SAT	= 6 ;   (* 7 days a week, Saturday is the first day	*)

(* constants for Locale.loc_MonPositiveSpaceSep and	*)
(* Locale.loc_MonNegativeSpaceSep			*)
  SS_NOSPACE	= 0 ;   (* cur. symbol is NOTseparated from value with a space*)
  SS_SPACE	= 1 ;   (* cur. symbol IS separated from value with a space   *)

(* constants for Locale.loc_MonPositiveSignPos and	*)
(* Locale.loc_MonNegativeSignPos			*)
  SP_PARENS	= 0 ;	(* () surround the quantity and currency_symbol   *)
  SP_PREC_ALL	= 1 ;	(* sign string comes before amount and symbol	  *)
  SP_SUCC_ALL	= 2 ;	(* sign string comes after amount and symbol	  *)
  SP_PREC_CURR	= 3 ;	(* sign string comes right before currency symbol *)
  SP_SUCC_CURR	= 4 ;	(* sign string comes right after currency symbol  *)

(* constants for Locale.loc_MonPositiveCSPos and Locale.loc_MonNegativeCSPos *)
  CSP_PRECEDES	= 0 ;	(* currency symbol comes before value *)
  CSP_SUCCEEDS	= 1 ;	(* currency symbol comes after value  *)

(* elements of the byte arrays pointed to by:				    *)
(*   Locale.loc_Grouping						    *)
(*   Locale.loc_FracGrouping						    *)
(*   Locale.loc_MonGrouping						    *)
(*   Locale.loc_MonFracGrouping						    *)
(* are interpreted as follows:						    *)
(*									    *)
(*    255     indicates that no further grouping is to be performed	    *)
(*    0       indicates that the previous element is to be repeatedly used  *)
(*	      for the remainder of the digits				    *)
(*    <other> the number of digits that comprises the current group	    *)

(*===========================================================================*)

(* Tags for OpenCatalog() *)
CONST
  OC_TagBase	     = TAG_USER + 090000H ;
  OC_BuiltInLanguage = OC_TagBase+1 ;  (* language of built-in strings    *)
  OC_BuiltInCodeSet  = OC_TagBase+2 ;  (* code set of built-in strings    *)
  OC_Version	     = OC_TagBase+3 ;  (* catalog version number required *)
  OC_Language	     = OC_TagBase+4 ;  (* preferred language of catalog   *)

(*===========================================================================*)

(* Comparison types for StrnCmp() *)
CONST
  SC_ASCII    = 0 ;
  SC_COLLATE1 = 1 ;
  SC_COLLATE2 = 2 ;

(*===========================================================================*)

(* This structure must only be allocated by locale.library and is READ-ONLY! *)
TYPE
  CatalogPtr = POINTER TO Catalog ;
  Catalog = RECORD
    cat_Link     : Node     ; (* for internal linkage    *)
    cat_Pad	 : CARDINAL ; (* to longword align	 *)
    cat_Language : STRING   ; (* language of the catalog *)
    cat_CodeSet  : LONGINT  ; (* currently always 0	 *)
    cat_Version  : CARDINAL ; (* version of the catalog  *)
    cat_Revision : CARDINAL ; (* revision of the catalog *)
  END ;

(*===========================================================================*)

VAR
  LocaleBase : LocaleBasePtr ;

(*--- functions in V38 or higher (Release 2.1) ---*)

PROCEDURE CloseCatalog( catalog : CatalogPtr ) ;
PROCEDURE CloseLocale ( locale  : LocalePtr  ) ;

PROCEDURE ConvToLower( locale : LocalePtr ; character : LONGINT ) : LONGINT ;
PROCEDURE ConvToUpper( locale : LocalePtr ; character : LONGINT ) : LONGINT ;

PROCEDURE FormatDate( locale      : LocalePtr ;
		      fmtTemplate : STRING ;
		      date	  : DateStampPtr ;
		      putCharFunc : HookPtr ) ;

PROCEDURE FormatString( locale	    : LocalePtr ;
		        fmtTemplate : STRING ;
		        dataStream  : ADDRESS ;
			putCharFunc : HookPtr ) : ADDRESS ;

PROCEDURE GetCatalogStr( catalog	: CatalogPtr ;
			 stringNum	: LONGINT ;
			 defaultString  : STRING ) : STRING ;

PROCEDURE GetLocaleStr( locale : LocalePtr ; stringNum : LONGINT ) : STRING ;

PROCEDURE IsAlNum ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsAlpha ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsCntrl ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsDigit ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsGraph ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsLower ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsPrint ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsPunct ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsSpace ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsUpper ( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;
PROCEDURE IsXDigit( locale : LocalePtr ; character : LONGINT ) : BOOLEAN ;

PROCEDURE OpenCatalogA( locale : LocalePtr ;
			name   : STRING ;
			tags   : TagItemPtr ) : CatalogPtr ;

PROCEDURE OpenCatalog( locale : LocalePtr ;
		       name   : STRING ;
		       tag1   : Tag ; .. ) : CatalogPtr ;

PROCEDURE OpenLocale( name : STRING ) : LocalePtr ;

PROCEDURE ParseDate( locale : LocalePtr ;
		     date : DateStampPtr ;
		     fmtTemplate : STRING ;
		     getCharFunc : HookPtr ) : BOOLEAN ;

PROCEDURE StrConvert( locale : LocalePtr ;
		      string : STRING ;
		      buffer : ADDRESS ;
		      bufferSize, type : LONGINT ) : LONGINT ;

PROCEDURE StrnCmp( locale : LocalePtr ;
		   string1 , string2 : STRING ;
		   length, type : LONGINT ) : LONGINT ;

END Locale.
